<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>东单办公系统-部门修改</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		  content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="media/layui/css/layui.css" media="all">
	<script type="text/javascript" src="media/js/jquery.min.js"></script>
	<script src="media/layui/layui.js"></script>
	<script type="text/javascript">
		$(function () {
			var json=getData();
			var obj=JSON.parse(decodeURI(json));
			showData(obj);
		})

		function getData() {
			var url=window.location.search;
			index=url.indexOf("?");
			if(index>-1){
				var str = url.substr(index+1);
				if(str.indexOf('=')){
					return str.split('=')[1];
				}
			}
			return null;
		}
		function showData(obj) {
			$("#f1").val(obj.id);
			$("#f2").val(obj.name);
			$("#f3").val(obj.createtime);
		}
	</script>
</head>
<body>

<div class="layui-container" style="margin-top: 5px">
	<form class="layui-form" >
		<div class="layui-form-item">
			<label class="layui-form-label">部门序号</label>
			<div class="layui-input-block">
				<input type="text" name="id" readonly="readonly" autocomplete="off"
					   class="layui-input" id="f1">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">部门名称</label>
			<div class="layui-input-block">
				<input type="text" name="name" lay-verify="require" autocomplete="off"
					   class="layui-input" id="f2">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">成立日期</label>
			<div class="layui-input-block">
				<input type="text" name="createtime" readonly="readonly" id="f3" autocomplete="off" class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<button class="layui-btn" style="margin-left: 100px" type="button" onclick="clickit()">提交</button>
		</div>
	</form>
</div>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
	function clickit() {
		$.ajax({
			type:"post",
			data:$('form').serialize(),
			url:"/departupdate.do",
			success:function (data) {
				if(data.code == 0){
					console.log("修改成功")
					window.location.href='departlist.html'
				}
			}
		})
	}
</script>
<script>
	layui.use([ 'form', 'laydate' ],
			function() {
				var form = layui.form, layer = layui.layer, laydate = layui.laydate;

			});
</script>
</body>
</html>